#!/usr/bin/env bash
# -*- zh_CN.utf-8 -*-
# @Date    : 2021-05-15
# @Version : v0.1
# @Explain : 批量修改密码 暂支持centos7

checkSystem() {
    if [ ! -f /etc/redhat-release ];then
        echo "系统非centos"
        exit 0
    else
        [ -z "$(grep ' 7.*' /etc/redhat-release)" ] && {
            echo "系统非 centos 7"
            exit 0
        }
    fi
}

checkInit() {
    if [ "$USER" == "jmsadmin" ] || [ "$USER" == "jmsuser" ];then
        echo "请勿使用跳板机使用该脚本."
        exit 0
    fi
}

passwdUser() {
    userName=${USER}
    echo "修改 ${userName} 用户密码"
    sudo passwd ${userName}
}

checkSystem
checkInit
passwdUser